<template>
  <el-aside :width="width">
    <h4>千锋管理系统</h4>
    <el-menu v-if="userInfo.adminname==='admin'" :collapse="collapse" router background-color="#2D3436">
      <el-menu-item index="/home">首页</el-menu-item>
      <el-sub-menu index="1">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>账户管理</span>
        </template>

        <el-menu-item index="/home/manage/managelist">
          <span>管理员列表</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="2">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>轮播图管理</span>
        </template>
        <el-menu-item index="/home/swipemanage/swipelist">
          <span>轮播图列表</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="3">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>产品管理</span>
        </template>
        <el-menu-item index="/home/productmanage/productlist">
          <span>产品列表</span>
        </el-menu-item>
        <el-menu-item index="/home/productmanage/secondkilllist">
          <span>秒杀列表</span>
        </el-menu-item>
        <el-menu-item index="/home/productmanage/recomendlist">
          <span>推荐列表</span>
        </el-menu-item>
        <el-menu-item index="/home/productmanage/filterlist">
          <span>筛选列表</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="4">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>数据可视化</span>
        </template>
        <el-menu-item index="/home/echartsmanage/echartsshow">
          <span>Echarts数据展示</span>
        </el-menu-item>
        <el-menu-item index="/home/echartsmanage/echartsother">
          <span>Echarts其他数据</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="5">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>编辑器</span>
        </template>
        <el-menu-item index="/home/editor/editorsubmit">
          <span>富文本编辑器</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="6">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>地图</span>
        </template>
        <el-menu-item index="/home/map/mapbaidu">
          <span>我的地图</span>
        </el-menu-item>
      </el-sub-menu>
    </el-menu>
    <el-menu v-else :collapse="collapse" :default-openeds="['1', '3']" router background-color="#2D3436">
      <el-sub-menu v-for="item in userInfo.checkedkeys" :index="`/home/${item.path}`">
        <template #title>
          <el-icon>
            <Location />
          </el-icon>
          <span>{{item.label}}</span>
        </template>

        <el-menu-item v-for="subitem in item.children" :index="`/home/${item.path}/${subitem.path}`">
          <span>{{subitem.label}}</span>
        </el-menu-item>
      </el-sub-menu>
    </el-menu>
  </el-aside>
</template>

<script>
import { Location } from '@element-plus/icons-vue';
export default {
  props: ['width', 'collapse'],
  components: {
    Location
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo;
    }
  }
};
</script>
<style scoped>
.el-aside {
  background: #2d3436;
  color: white;
}
.el-menu {
  border: 0;
  color: white;
}
.el-menu-item,
.el-sub-menu span,
.el-icon {
  color: #f2fff2 !important;
}
</style>